<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>vue</title>
</head>
<body>

<div id="app">
    <router-link to="/account">account</router-link>
    <router-view></router-view>
</div>

<template id="tpl">
    <div>
        <h1>一级路由</h1>
        <router-link to="/account/login">login</router-link>
        <router-link to="/account/reg">register</router-link>
        <router-view></router-view>
    </div>
</template>

<script src="https://unpkg.com/vue/dist/vue.js"></script>
<script src="https://unpkg.com/vue-router/dist/vue-router.js"></script>
<script>

    let account = {
        template: '#tpl'
    };

    let login  = {
        template: '<h1>login</h1>',
    };

    let reg  = {
        template: '<h2>register</h2>',
    };

    let router = new VueRouter({
        routes: [
            {
                path: '/account',
                component: account,
                children: [
                    {path: 'login', component: login},
                    {path: 'reg', component: reg},
                ]
            },
        ]
    });

    let vm = new Vue({
        el: "#app",
        data: {
        },
        router
    })

</script>
</body>
</html>
